﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class bookDetail : System.Web.UI.Page
{
    protected EbookDetail selectedBook = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        int bookId = 0;
        if (Request.QueryString["BookId"] != null)
        {
            bookId = Convert.ToInt32(Request.QueryString["BookId"]);
        }

        if (bookId > 0)
        {
            selectedBook = EbookDetail.GetEBooks(bookId);

            ltTitle.Text = selectedBook.Title;
            ltAuthor.Text = selectedBook.Authors;
            ltPublishedYear.Text = selectedBook.PublishedYear.ToString();
            ltSummary.Text = selectedBook.Summary;

            ltPublisher.Text = Publisher.GetAllPublishers().Find(x => x.Id == selectedBook.PublisherId).PublisherName;
            ltCategory.Text = Category.GetAllCategories().Find(x => x.Id == selectedBook.CategoryId).CategoryName;

            imgThumnail.ImageUrl = "DBImageHandler.ashx?imgID=" + selectedBook.ThumbnailId;

            hplDownload.NavigateUrl = selectedBook.Link;
        }
    }
}